package com.hjk.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class RedisService {

    @Autowired
    RedisTemplate redisTemplate;

    public void test1(){

        ValueOperations opsForValue = redisTemplate.opsForValue();

        opsForValue.set("a","a");

        // set if not exit,如果不存在才设置
        opsForValue.setIfAbsent("key","value");


        redisTemplate.opsForHash().put("a","a",10);

    }

}
